# constants.py

# Response codes:
RESPONSE = {
    'OK'    : 'OK',
    'ERR'   : 'Command format error / Value error',
    'NG'    : 'The command is invalid at this time',
    'FER'   : 'Framing error',
    'ORER'  : 'Overrun error'
}

# System or Site types
SYS_TYPE = {
    'Conventional'      : 'CNV',
    'MOTOROLA'          : 'MOT',
    'EDACS Narrow/Wide' : 'EDC',
    'EDACS SCAT'        : 'EDS',
    'LTR'               : 'LTR',
    'P25 STANDARD'      : 'P25S',
    'P25 One Frequency' : 'P25F'
}

# Key codes
KEY_CODE = {
    'MENU'  : 'M',
    'FUNC'  : 'F',
    'HOLD'  : 'H',
    'SCAN'  : 'S',
    'L/O'   : 'L',
    '1'     : '1',
    '2'     : '2',
    '3'     : '3',
    '4'     : '4',
    '5'     : '5',
    '6'     : '6',
    '7'     : '7',
    '8'     : '8',
    '9'     : '9',
    '0'     : '0',
    './NO'  : '.',
    'E/YES' : 'E',
    '>'     : '>', # Knob right
    '<'     : '<', # Knob left
    'Push'  : '^', # Knob push
    'PWR'   : 'P'
}

# Key press modes
KEY_MODE = {
    'Press'         : 'P',
    'Long Press'    : 'L',
    'Hold'          : 'H', # Hold key until cancelled
    'Release'       : 'R', # Cancel hold
}

# List of system fields
SYS_FIELDS = [
    'SYS_TYPE', 'NAME', 'QUICK_KEY', 'HLD', 'LOUT', 'DLY', 'RSV01', 'RSV02',
    'RSV03', 'RSV04', 'RSV05', 'REV_INDEX', 'FWD_INDEX', 'CHN_GRP_HEAD',
    'CHN_GRP_TAIL', 'SEQ_NO', 'START_KEY', 'RSV06', 'RSV07', 'RSV08', 'RSV09',
    'RSV10', 'NUMBER_TAG', 'AGC_ANALOG', 'AGC_DIGITAL', 'P25WAITING',
    'PROTECT', 'RSV11']

# List of trunk fields
TRUNK_FIELDS = [
    'ID_SEARCH', 'S_BIT', 'END_CODE', 'AFS', 'RSV01', 'RSV02', 'EMG', 'EMGL',
    'FMAP', 'CTM_FMAP', 'RSV03', 'RSV04', 'RSV05', 'RSV06', 'RSV07', 'RSV08',
    'RSV09', 'RSV10', 'RSV11', 'RSV12', 'TGID_GRP_HEAD', 'TGID_GRP_TAIL',
    'ID_LOUT_GRP_HEAD', 'ID_LOUT_GRP_TAIL', 'MOT_ID', 'EMG_COLOR',
    'EMG_PATTERN', 'P25NAC', 'PRI_ID_SCAN']

# List of site fields
SITE_FIELDS = [
    'RSV01', 'NAME', 'QUICK_KEY', 'HLD', 'LOUT', 'MOD', 'ATT', 'C-CH', 'RSV02',
    'RSV03', 'REV_INDEX', 'FWD_INDEX', 'SYS_INDEX', 'CHN_HEAD', 'CHN_TAIL',
    'SEQ_NO', 'START_KEY', 'LATITUDE', 'LONGITUDE', 'RANGE', 'GPS_ENABLE',
    'RSV04', 'MOT_TYPE', 'EDACS_TYPE', 'P25WAITING', 'RSV05']

# List of group fields
GROUP_FIELDS = [
    'GRP_TYPE', 'NAME', 'QUICK_KEY', 'LOUT', 'REV_INDEX', 'FWD_INDEX',
    'SYS_INDEX', 'CHN_HEAD', 'CHN_TAIL', 'SEQ_NO', 'LATITUDE', 'LONGITUDE',
    'RANGE', 'GPS_ENABLE']

# List of channel fields
CHANNEL_FIELDS = [
    'NAME', 'FRQ', 'MOD', 'CTCSS_DCS', 'TLOCK', 'LOUT', 'PRI', 'ATT', 'ALT',
    'ALTL', 'REV_INDEX', 'FWD_INDEX', 'SYS_INDEX', 'GRP_INDEX', 'RSV01',
    'AUDIO_TYPE', 'P25NAC', 'NUMBER_TAG', 'ALT_COLOR', 'ALT_PATTERN',
    'VOL_OFFSET']

# List of TGID fields
TGID_FIELDS = [
    'NAME', 'TGID', 'LOUT', 'PRI', 'ALT', 'ALTL', 'REV_INDEX', 'FWD_INDEX',
    'SYS_INDEX', 'GRP_INDEX', 'RSV01', 'AUDIO_TYPE', 'NUMBER_TAG', 'ALT_COLOR',
    'ALT_PATTERN', 'VOL_OFFSET']

# List of display fields
DISPLAY_FIELDS = [
    'DSP_FORM', 'L1_CHAR', 'L1_MODE', 'L2_CHAR', 'L2_MODE', 'L3_CHAR',
    'L3_MODE', 'L4_CHAR', 'L4_MODE', 'L5_CHAR', 'L5_MODE', 'L6_CHAR',
    'L6_MODE', 'L7_CHAR', 'L7_MODE', 'L8_CHAR', 'L8_MODE', 'SQL', 'MUT', 'BAT',
    'WAT', 'RSV01', 'RSV02', 'SIG_LVL', 'BK_COLOR', 'BK_DIMMER']

# List of reception status fields
RECEPTION_FIELDS = [
    'FRQ/TGID', 'MOD', 'ATT', 'CTCSS_DCS', 'NAME1', 'NAME2', 'NAME3', 'SQL',
    'MUT', 'SYS_TAG', 'CHAN_TAG', 'P25NAC']

# List of coverage bands
BAND_COVERAGE = [
    '25.0', '26.9', '27.4', '28.0', '29.7', '50.0', '54.0', '72.0', '76.0',
    '88.0', '108.0', '137.0', '144.0', '148.0', '150.8', '162.0', '174.0',
    '216.0', '225.0', '380.0', '400.0', '406.0', '420.0', '450.0', '470.0',
    '758.0', '788.0', '806.0', '849.0', '894.0', '1240.0']

# System data structure
SYSTEM = {
    'SYS_TYPE'      : '',
    'NAME'          : '',
    'QUICK_KEY'     : '',
    'HLD'           : '',
    'LOUT'          : '',
    'DLY'           : '',
    'RSV01':'', 'RSV02':'', 'RSV03':'', 'RSV04':'', 'RSV05':'',
    'REV_INDEX'     : '',
    'FWD_INDEX'     : '',
    'CHN_GRP_HEAD'  : '',
    'CHN_GRP_TAIL'  : '',
    'SEQ_NO'        : '',
    'START_KEY'     : '',
    'RSV06':'', 'RSV07':'', 'RSV08':'', 'RSV09':'', 'RSV10':'',
    'NUMBER_TAG'    : '',
    'AGC_ANALOG'    : '',
    'AGC_DIGITAL'   : '',
    'P25WAITING'    : '',
    'PROTECT'       : '',
    'RSV11':''
    }

# Trunk data structure
TRUNK = {
    'ID_SEARCH'         : '',
    'S_BIT'             : '',
    'END_CODE'          : '',
    'AFS'               : '',
    'RSV01':'', 'RSV02':'',
    'EMG'               : '',
    'EMGL'              : '',
    'FMAP'              : '',
    'CTM_FMAP'          : '',
    'RSV03':'', 'RSV04':'', 'RSV05':'', 'RSV06':'', 'RSV07':'', 'RSV08':'',
    'RSV09':'', 'RSV10':'', 'RSV11':'', 'RSV12':'',
    'TGID_GRP_HEAD'     : '',
    'TGID_GRP_TAIL'     : '',
    'ID_LOUT_GRP_HEAD'  : '',
    'ID_LOUT_GRP_TAIL'  : '',
    'MOT_ID'            : '',
    'EMG_COLOR'         : '',
    'EMG_PATTERN'       : '',
    'P25NAC'            : '',
    'PRI_ID_SCAN'       : ''
    }

# Site data structure
SITE = {
    'RSV01'         : '',
    'NAME'          : '',
    'QUICK_KEY'     : '',
    'HLD'           : '',
    'LOUT'          : '',
    'MOD'           : '',
    'ATT'           : '',
    'C-CH'          : '',
    'RSV02':'', 'RSV03':'',
    'REV_INDEX'     : '',
    'FWD_INDEX'     : '',
    'SYS_INDEX'     : '',
    'CHN_HEAD'      : '',
    'CHN_TAIL'      : '',
    'SEQ_NO'        : '',
    'START_KEY'     : '',
    'LATITUDE'      : '',
    'LONGTITUDE'    : '',
    'RANGE'         : '',
    'GPS_ENABLE'    : '',
    'RSV04'         : '',
    'MOT_TYPE'      : '',
    'EDACS_TYPE'    : '',
    'P25WAITING'    : '',
    'RSV05'         : ''
    }

# Group data structure
GROUP = {
    'GRP_TYPE'      : '',
    'NAME'          : '',
    'QUICK_KEY'     : '',
    'LOUT'          : '',
    'REV_INDEX'     : '',
    'FWD_INDEX'     : '',
    'SYS_INDEX'     : '',
    'CHN_HEAD'      : '',
    'CHN_TAIL'      : '',
    'SEQ_NO'        : '',
    'LATITUDE'      : '',
    'LONGITUDE'     : '',
    'RANGE'         : '',
    'GPS_ENABLE'    : ''
    }

# Channel data structure
CHANNEL = {
    'NAME'          : '',
    'FRQ'           : '',
    'MOD'           : '',
    'CTCSS_DCS'     : '',
    'TLOCK'         : '',
    'LOUT'          : '',
    'PRI'           : '',
    'ATT'           : '',
    'ALT'           : '',
    'ALTL'          : '',
    'REV_INDEX'     : '',
    'FWD_INDEX'     : '',
    'SYS_INDEX'     : '',
    'GRP_INDEX'     : '',
    'RSV01'         : '',
    'AUDIO_TYPE'    : '',
    'P25NAC'        : '',
    'NUMBER_TAG'    : '',
    'ALT_COLOR'     : '',
    'ALT_PATTERN'   : '',
    'VOL_OFFSET'    : ''
    }

# TGID data structure
TGID = {
    'NAME'          : '',
    'TGID'          : '',
    'LOUT'          : '',
    'PRI'           : '',
    'ALT'           : '',
    'ALTL'          : '',
    'REV_INDEX'     : '',
    'FWD_INDEX'     : '',
    'SYS_INDEX'     : '',
    'GRP_INDEX'     : '',
    'RSV01'         : '',
    'AUDIO_TYPE'    : '',
    'NUMBER_TAG'    : '',
    'ALT_COLOR'     : '',
    'ALT_PATTERN'   : '',
    'VOL_OFFSET'    : ''
    }

# Search configuration structure
SEARCH_STRUCTURE = {
    'FRQ'           : '',       # Frequency, 8 digits, no decimal
    'RSV01'         : '',       # RESERVED
    'MOD'           : 'AUTO',   # Modulation (AUTO/AM/FM/NFM/WFM/FMB)
    'ATT'           : '0',      # Attenuator (0:OFF/1:ON)
    'DLY'           : '0',      # Delay (-10,-5,-2,0,2,5,10,30)
    'RSV02'         : '',       # RESERVED
    'CODE_SRCH'     : '0',      # Code search (0:OFF / 1:CTCSS/DCS / 2:P25 NAC)
    'BSC'           : '000000000000000',    # Broadcast screen
    'REP'           : '0',      # Repeater find (0:OFF/1:ON)
    'RSV03'         : '',       # RESERVED
    'AGC_ANALOG'    : '1',      # Analog AGC (0:OFF/1:ON)
    'AGC_DIGITAL'   : '1',      # Digital AGC (0:OFF/1:ON)
    'P25WAITING'    : '400'     # P25 Wait time (0,100,200,300, ... ,900,1000)
    }

# Menu definitions
MENU_INDEX = {
    'Service Search'            : 'SVC_MENU',
    'WX Select'                 : 'WX_MENU',
    'Close Call Band Filter'    : 'CCBAND_MENU',
    'Broadcast Screen Band'     : 'SCR_OPT_MENU',
    'Global Lockout List'       : 'GL_LIST_MENU',
    'Setting Menu'              : 'SETTING_MENU'
    }

# Jump modes
JUMP_MODE = {
    'Scan'              : 'SCN_MODE',
    'Service Search'    : 'SVC_MODE',
    'Custom Search'     : 'CTM_MODE',
    'Close Call Only'   : 'CC_MODE',
    'WX scan'           : 'WX_MODE',
    'Tone-Out'          : 'FTO_MODE'
    }

# Display data structure
DISPLAY = {
    'DSP_FORM'  : '',
    'L1_CHAR'   : '',
    'L1_MODE'   : '',
    'L2_CHAR'   : '',
    'L2_MODE'   : '',
    'L3_CHAR'   : '',
    'L3_MODE'   : '',
    'L4_CHAR'   : '',
    'L4_MODE'   : '',
    'L5_CHAR'   : '',
    'L5_MODE'   : '',
    'L6_CHAR'   : '',
    'L6_MODE'   : '',
    'L7_CHAR'   : '',
    'L7_MODE'   : '',
    'L8_CHAR'   : '',
    'L8_MODE'   : '',
    'SQL'       : '',
    'MUT'       : '',
    'BAT'       : '',
    'WAT'       : '',
    'RSV01'     : '',
    'RSV02'     : '',
    'SIG_LVL'   : '',
    'BK_COLOR'  : '',
    'BK_DIMMER' : ''
    }

# Reception data structure
RECEPTION = {
    'FRQ/TGID'  : '',
    'MOD'       : '',
    'ATT'       : '',
    'CTCSS/DCS' : '',
    'NAME1'     : '',
    'NAME2'     : '',
    'NAME3'     : '',
    'SQL'       : '',
    'MUT'       : '',
    'SYS_TAG'   : '',
    'CHAN_TAG'  : '',
    'P25NAC'    : ''
    }